<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
    <title>用户注册</title>
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-5">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h4>用户注册</h4>
                </div>
                <div class="card-body">
                    <form:form modelAttribute="user" action="/user/register" method="post">
                        <div class="form-group">
                            <label for="username">用户名</label>
                            <form:input path="username" id="username" class="form-control" required="true"/>
                            <form:errors path="username" cssClass="text-danger"/>
                            <c:if test="${not empty error}">
                                <span class="text-danger">${error}</span>
                            </c:if>
                        </div>
                        <div class="form-group">
                            <label for="password">密码</label>
                            <form:password path="password" id="password" class="form-control" required="true"/>
                            <form:errors path="password" cssClass="text-danger"/>
                        </div>
                        <div class="form-group">
                            <label for="realName">真实姓名</label>
                            <form:input path="realName" id="realName" class="form-control"/>
                        </div>
                        <div class="form-group">
                            <label for="role">角色</label>
                            <form:select path="role" id="role" class="form-control">
                                <form:option value="ADMIN">管理员</form:option>
                                <form:option value="TEACHER">教师</form:option>
                                <form:option value="STUDENT">学生</form:option>
                            </form:select>
                        </div>
                        <button type="submit" class="btn btn-primary btn-block">注册</button>
                    </form:form>
                </div>
                <div class="card-footer text-center">
                    已有账号？<a href="/user/login">立即登录</a>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/static/js/jquery-3.6.0.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</body>
</html>